<?php

namespace App\Modules\Admin\Services\Bus;

use App\Exceptions\Exception;
use App\Library\Junda\src\EquipmentService;
use App\Modules\Admin\Entities\Member\UserExtractModel;
use App\Modules\Admin\Services\BaseService;
use Illuminate\Support\Facades\DB;

class UserExtractService extends BaseService
{

    public function __construct(UserExtractModel $model)
    {
        $this->model = $model;
        $this->with=['user_info','bank_info'];
    }
    public function lists(array $params) : array
    {
        $params['where_callback'] = function($query) use ($params){
            $request = request();
            // 按照名称进行搜索
            $month = $request->input('month', '');
            if (!empty($month)){
                $query->where('month', $month);
            }
        };
        return parent::lists($params); // TODO: Change the autogenerated stub
    }
    public function confirmpayment($params)
    {
        DB::beginTransaction();
        try{
          parent::update(['id'=>$params['id'],'status'=>1]);
            DB::commit();
            return true;
        }catch (Exception $e){
            DB::rollBack();
            throw new Exception($e->getMessage());
        }

    }
}
